package com.joolun.web.api;

import com.joolun.common.core.domain.AjaxResult;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joolun.mall.entity.InviteUser;
import com.joolun.mall.entity.UserAddress;
import com.joolun.mall.service.InviteUserInfoService;
import com.joolun.mall.service.InviteUserService;
import com.joolun.weixin.service.WxUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/*
* 邀约用户
* */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/weixin/api/ma/inviteuser")
@Api(value = "inviteuser", tags = "邀约用户API")
public class InviteUserApi {

    private final InviteUserService inviteuserService;
    private final WxUserService wxUserService;


    /**
     * 分页查询邀约用户
     * @param page 分页对象
     * @return
     */
    @ApiOperation(value = "分页查询")
    @GetMapping("/page")
    public AjaxResult getInviteUserInfoPage(Page page) {
        return AjaxResult.success(wxUserService.selectInviteUserPage(page));
    }

    /**
     * 新增、修改邀约用户
     * @param inviteuser 邀约用户
     * @return AjaxResult
     */
    @ApiOperation(value = "新增、修改邀约用户")
    @PostMapping
    public AjaxResult save(@RequestBody InviteUser inviteuser){
        return AjaxResult.success(inviteuserService.saveOrUpdate(inviteuser));
    }

}
